package cn.wolfcode.trip.api.controller;

import cn.wolfcode.trip.base.domain.Daily;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IDailyService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/dailies")
public class DailyController {
    @Autowired
    private IDailyService dailyService;

    /**
     * 查询已发布的日报
     */
    @GetMapping("/list")
    public PageInfo<Daily> list(QueryObject qo) {
        PageInfo<Daily> pageInfo = dailyService.queryForApp(qo);
        return pageInfo;
    }

    /**
     * 查询热门的日报
     * 注意:只有一条日报是热门的
     */
    @GetMapping("/selectHotDaily")
    public Daily selectHotDaily(Integer sequence) {
        Daily daily = dailyService.selectHotDaily(sequence);
        return daily;
    }

    /**
     * 查询日报内容
     */
    @GetMapping("/selectById/{id}")
    public Daily selectContentById(@PathVariable Long id) {
        Daily daily = dailyService.selectById(id);
        return daily;
    }

    /**
     * 增加浏览量
     */
    @GetMapping("/updateBrowseNumById/{id}")
    public void updateBrowseNumById(@PathVariable Long id) {
       dailyService.updateBrowseNumById(id);
    }


}
